<?php
/**
 * Created by JetBrains PhpStorm.
 * User: oleg
 * Date: 03.11.11
 * Time: 23:00
  */
 
class EmailTemplates extends BaseDBModel {

    public function __construct()
    {
        $this->tableName = 'email_template';
        $this->primaryKey = 'change_pass_subject';
    }

    public function getTemplates()
    {
        $templates = Yii::app()->cache->get('email_template');
        if ($templates === false) {
            $templates = $this->getOne('1=1');
            Yii::app()->cache->set('email_template', $templates);
        }
        return $templates;
    }

    public function setTemplates($templates)
    {
        Yii::app()->cache->delete('email_template');
        return $this->update($templates);
    }
}
